﻿using _15Net8AspNetCore_ORM.Context;
using Microsoft.EntityFrameworkCore;

namespace _15Net8AspNetCore_ORM.OrderRespository
{
    public class OrderReposotoryOptions
    {
        public IServiceCollection Services { get; set; }
        public ConfigurationManager Configuration { get; set; }

        public void UseEFCore()
        {
            Services.AddDbContext<EFCoreDBContext>(
                option => option.UseMySql(Configuration.GetConnectionString("DefaultConnection"), new MySqlServerVersion("5.7.29")), ServiceLifetime.Singleton);

            Services.AddSingleton<IOrderRespository, OrderEFCoreRespository>();
        }

        public void UseDapper()
        {
            Services.AddSingleton<DapperDBContext>();

            Services.AddSingleton<IOrderRespository, OrderDapperRespository>();
        }


        public void UseSqlSugar()
        {
            Services.AddSingleton(new SqlSugarDBContext(Configuration));

            Services.AddSingleton<IOrderRespository, OrderSqlSugarRespository>();
        }
    }
}
